package com.buildings.base;

import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.GeolocationPermissions;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.OptionsPickerView;
import com.buildings.R;
import com.buildings.activity.RegisterActivity;
import com.buildings.activity.TownHouseFormActivity;
import com.buildings.api.Api;
import com.buildings.api.Constant;
import com.buildings.bean.BuildingCodeBean;
import com.buildings.bean.DivisionResultBean;
import com.buildings.bean.ImageURL;
import com.buildings.bean.LoginBean;
import com.buildings.bean.TownHouseBean;
import com.buildings.bean.TownHouseResultBean;
import com.buildings.http.BaseCallBack;
import com.buildings.http.JsonBuilder;
import com.buildings.http.MyHttpClient;
import com.buildings.util.CustomToast;
import com.buildings.util.DialogUtils;
import com.buildings.util.SPUtil;
import com.buildings.util.Utils;
import com.buildings.view.MyGridView;
import com.bumptech.glide.Glide;
import com.githang.statusbar.StatusBarCompat;
import com.yuyh.library.imgsel.ISNav;

import com.yuyh.library.imgsel.common.ImageLoader;
import com.yuyh.library.imgsel.config.ISListConfig;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 *
 */

public class BaseFormActivity extends BaseActivity {

    private static final int REQUEST_CODE = 102;


    private PictureAdapter adapter;
    public List<ImageURL> listUrl;//本地图片地址集合
    private ArrayList<String> uploadUrl;//上传图片地址集合
    private int imageNum = 5;//选择图片个数
    protected int W ;
    protected int H;


    public Dialog myDialog;

    public String province ="";
    public String city="";
    public String area="";
    public String buildingCode="";

    public List<DivisionResultBean.Division> provinceList;
    public List<DivisionResultBean.Division> cityList;
    public List<DivisionResultBean.Division> areaList;
    public DivisionResultBean.Division provinceBean;
    public DivisionResultBean.Division cityBean;
    public DivisionResultBean.Division areaBean;


    public void setProvinceText(String province){}
    public void setCityText(String city){}
    public void setAreaText(String area){}

    public long mCurrentTime;


    private void showPickerView(final List<DivisionResultBean.Division> list, final String type) {// 弹出选择器（省市区三级联动）
        OptionsPickerView pvOptions = new OptionsPickerView.Builder(this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                DivisionResultBean.Division division = list.get(options1);
                switch (type){
                    case RegisterActivity.PROVINCE:
                        provinceBean = division;
                        province = division.getDivisionName();
                        cityBean = null;
                        areaBean = null;
                        city="";
                        area = "";
                        setCityText("");
                        setAreaText("");
                        setProvinceText(division.getDivisionName());

                        break;
                    case RegisterActivity.CITY:
                        cityBean = division;
                        areaBean = null;
                        area = "";
                        setAreaText("");
                        setCityText(division.getDivisionName());
                        city = division.getDivisionName();
                        break;
                    case RegisterActivity.AREA:
                        areaBean = division;
                        setAreaText(division.getDivisionName());
                        area = division.getDivisionName();
                        break;
                }

                //返回的分别是三个级别的选中位置
//                etAddress.setText(options1Items.get(options1).getPickerViewText() + "  "
//                        + options2Items.get(options1).get(options2) );

            }
        })
                .setTitleText("城市选择")
                .setDividerColor(Color.BLACK)
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(20)
                .build();
        pvOptions.setPicker(list);//一级选择器
//        pvOptions.setPicker(options1Items, options2Items);//二级选择器
//        pvOptions.setPicker(options1Items, options2Items, options3Items);//三级选择器
        pvOptions.show();
    }


    public void getDivisions(String divisionid, final String type, String provinceType, DivisionResultBean.Division division) {

        if(TextUtils.equals("Municipality",provinceType)){
            //省的直辖市
            if(TextUtils.equals(RegisterActivity.PROVINCE,type)){

            }else if(TextUtils.equals(RegisterActivity.CITY,type)){
                cityList = new ArrayList<>();
                if(division != null){
                    cityList.add(division);
                }
                showPickerView(cityList,RegisterActivity.CITY);
            }else if(TextUtils.equals(RegisterActivity.AREA,type)){

            }
        }else {
            if(myDialog == null){
                myDialog = DialogUtils.showRefreshDialog(activity);
            }else {
                myDialog.show();
            }
            //divisions/{divisionid}/subdivisions
            String url = Api.GET_LOCATION+"divisions/"+divisionid+"/subdivisions";
            MyHttpClient
                    .newBuilder()
                    .get()
                    .url(url)
//                .addParam(jsonBuilder.toJsonString())
                    .build()
                    .enqueue(new BaseCallBack<DivisionResultBean>() {
                        @Override
                        public void onSuccess(DivisionResultBean divisionResultBean) {
                            super.onSuccess(divisionResultBean);
                            if (myDialog != null)
                                myDialog.dismiss();
                            if(divisionResultBean != null && divisionResultBean.getCode() == 200){
                                if(divisionResultBean.getData() != null){
                                    if(TextUtils.equals(RegisterActivity.PROVINCE,type)){
                                        provinceList = divisionResultBean.getData();
                                        showPickerView(provinceList,RegisterActivity.PROVINCE);
                                    }else if(TextUtils.equals(RegisterActivity.CITY,type)){
                                        cityList = divisionResultBean.getData();
                                        showPickerView(cityList,RegisterActivity.CITY);
                                    }else if(TextUtils.equals(RegisterActivity.AREA,type)){
                                        areaList = divisionResultBean.getData();
                                        showPickerView(areaList,RegisterActivity.AREA);
                                    }

                                }
                            }

                        }

                        @Override
                        public void onFailure(Call call, IOException e) {
                            super.onFailure(call, e);
                            CustomToast.showToast(activity,"网络异常");

                            if (myDialog != null)
                                myDialog.dismiss();
                        }

                        @Override
                        public void onError(int code) {
                            super.onError(code);
                            CustomToast.showToast(activity,"网络异常");

                            if (myDialog != null)
                                myDialog.dismiss();
                        }
                    });
        }
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // 图片选择结果回调
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            List<String> pathList = data.getStringArrayListExtra("result");
            if(pathList != null && pathList.size() > 0){
                String toPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/" ;
                String path = pathList.get(0);
                String newPath = "";
                if(path != null && path.contains("com.buildings")){
                    //相机图片  会在项目目录缓存拍照图片，删除
                    newPath = Utils.savePictureBitmap(activity,path,toPath,true);
                    if(!TextUtils.isEmpty(newPath)){
                        if(myDialog != null){
                            myDialog.show();
                        }else {
                            myDialog = DialogUtils.showRefreshDialog(activity);
                        }
                        uploadImage(newPath,false);
                    }
                }else {
                    //选择图片
                    newPath = Utils.savePictureBitmap(activity,path,toPath,false);
                    if(!TextUtils.isEmpty(newPath)){
                        if(myDialog != null){
                            myDialog.show();
                        }else {
                            myDialog = DialogUtils.showRefreshDialog(activity);
                        }
                        uploadImage(newPath,true);
                    }

                }
//                String newPath = Utils.savePictureBitmap(path);
                Log.e("onActivityResult","图片地址 "+newPath);

            }
        }
    }

    private File cameraSavePath;//拍照照片路径
    private Uri uri;//照片uri

    //激活相机操作
    private void goCamera() {
        cameraSavePath = new File(Environment.getExternalStorageDirectory().getPath() + "/" + System.currentTimeMillis() + ".jpg");


        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            //第二个参数为 包名.fileprovider
            uri = FileProvider.getUriForFile(activity, "com.example.hxd.pictest.fileprovider", cameraSavePath);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        } else {
            uri = Uri.fromFile(cameraSavePath);
        }
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        startActivityForResult(intent, 1);
    }


    /**
     * 图片
     */
    public void selectImage() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&ActivityCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED ) {
            //用户没有给与相机授权
            Utils.askMultiPermission(activity, new SelectPermissionCallBack() {
                @Override
                public void onGranted() {

                }
            }, Manifest.permission.CAMERA);
            return;
        }
        // 自定义图片加载器
        ISNav.getInstance().init(new ImageLoader() {
            @Override
            public void displayImage(Context context, String path, ImageView imageView) {
                Glide.with(context).load(path).into(imageView);
            }
        });
//        Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//        startActivityForResult(intent,1001);

        ISListConfig config = new ISListConfig .Builder()
                // 是否多选
                .multiSelect(false)
                .btnText("Confirm")
                // 确定按钮背景色
                //.btnBgColor(Color.parseColor(""))
                // 确定按钮文字颜色
                .btnTextColor(Color.WHITE)
                // 使用沉浸式状态栏
                .statusBarColor(Color.parseColor("#5887F9"))
                .title("图片选择")
                .titleColor(Color.WHITE)
                .titleBgColor(Color.parseColor("#5887F9"))
                .allImagesText("All Images")
                .needCrop(false)
                .cropSize(1, 1, 200, 200)
                // 第一个是否显示相机
                .needCamera(true)
                // 最大选择图片数量
                .maxNum(9)
                .build();

//        ImgSelActivity.startActivity(this, config, REQUEST_CODE);
        // 跳转到图片选择器
        ISNav.getInstance().toListActivity(this, config, REQUEST_CODE);

    }


    /**
     *
     * @param fileUrl
     * @param isDelete  是否把上传完图片删除
     */
    public void uploadImage(final String fileUrl, final boolean isDelete){
        if(TextUtils.isEmpty(buildingCode)){
            CustomToast.showToast(activity,"建筑编码为空，不能上传图片");
            if (myDialog!=null&&myDialog.isShowing()){
                myDialog.dismiss();
            }
            return;
        }
//        setImage(fileUrl);
// 设置文件以及文件上传类型封装
        RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), new File(fileUrl));

        // 文件上传的请求体封装
        MultipartBody multipartBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("uploadFile", fileUrl, requestBody)
                .addFormDataPart("buildingCode", buildingCode+"")
                .build();

//        RequestBody requestBody = new MultipartBody.Builder()
//                .setType(MultipartBody.FORM)
//                .addFormDataPart("uploadFile", fileUrl)
//                .build();
        String token = (String) SPUtil.get("token","");

        final Request request = new Request.Builder()
                .addHeader("token",token)
                .url(Api.UPLOAD_IMAGE)
                .post(multipartBody)
                .build();
        OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder();
        httpBuilder.readTimeout(20000, TimeUnit.SECONDS)
                .connectTimeout(20000, TimeUnit.SECONDS)
                .writeTimeout(20000, TimeUnit.SECONDS)
                ;

        OkHttpClient okHttpClient = httpBuilder.build();

        okHttpClient.newCall(request).

                enqueue(new Callback() {
                    @Override
                    public void onFailure(Call call, IOException e) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if(myDialog != null){
                                    myDialog.dismiss();
                                }
                                CustomToast.showToast(activity,"图片上传失败");
                            }
                        });
                    }


                    @Override
                    public void onResponse(Call call, final Response response)throws IOException {
                        if(myDialog != null){
                            myDialog.dismiss();
                        }
                        if (response.isSuccessful()) {
                            final String result = response.body().string();
                            Log.e("imageResult",result+"");
                            if (response.body() != null) {
                                response.body().close();
                            }
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if(myDialog != null){
                                        myDialog.dismiss();
                                    }
                                    Log.e("Image",result+"");
                                    try {
                                        JSONObject jsonObject = new JSONObject(result);
                                        int code = jsonObject.getInt("code");
                                        if(code == 200){
                                            CustomToast.showToast(activity,"图片上传成功");
                                            String imageUrl = jsonObject.getString("data");
                                            ImageURL imageURL = new ImageURL();
                                            imageURL.setThumbnail(imageUrl);
                                            imageURL.setLocalPath(imageUrl);
                                            listUrl.add(imageURL);
                                            adapter.update(listUrl);
                                            setImage(imageUrl);
                                            if(isDelete){
                                                File file = new File(fileUrl);
                                                if(file.exists()){
                                                    file.delete();
                                                }
                                            }
                                        }else {
                                            CustomToast.showToast(activity,"图片上传失败");
                                        }
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                        CustomToast.showToast(activity,"图片上传失败");

                                    }
                                }
                            });

                        }
                    }

                });

    }

    private void getBuildingCode(String code, final EditText etNumber) {
        if(!TextUtils.isEmpty(code) && code.startsWith("156")){
           code =  code.substring(3);
        }
        String url = Api.BUILDING_CODE+"?divisionNum="+code;
        MyHttpClient
                .newBuilder()
                .get()
                .url(url)
//                .addParam(json)
                .build()
                .enqueue(new BaseCallBack<BuildingCodeBean>() {
                    @Override
                    public void onSuccess(BuildingCodeBean resultBean) {
                        super.onSuccess(resultBean);
                        if(resultBean.getCode() == 200 && resultBean.getData() != null){
                            etNumber.setText(resultBean.getData());
                            buildingCode = resultBean.getData();
                        }else {
                            CustomToast.showToast(activity, "获取建筑物编号失败");
                        }
                        if (myDialog != null)
                            myDialog.dismiss();
                    }

                    @Override
                    public void onFailure(Call call, IOException e) {
                        super.onFailure(call, e);
                        if (myDialog != null)
                            myDialog.dismiss();
                        CustomToast.showToast(activity, "获取建筑物编号失败");
                    }

                    @Override
                    public void onError(int code) {
                        super.onError(code);
                        if (myDialog != null)
                            myDialog.dismiss();
                        CustomToast.showToast(activity, "获取建筑物编号失败");
                    }
                });

    }


    /**
     * 调用天地图获取地理信息
     */
    public void getTianDiTuLocation(String lng, String lat,

                                     final EditText etBuildingAddress, final EditText etProvince,
                                     final EditText etCity, final EditText etArea,
                                    final EditText etBuildingName,final EditText etNumber, final EditText etBuildingStreet,final  EditText etXiaoQuMenPai) {

        String url = "http://api.tianditu.gov.cn/geocoder?postStr={'lon':"+lng+",'lat':"+lat+",'ver':1}&type=geocode&tk="+Constant.TIAN_DI_TU_ANDROID_KEY;
//        String url = "http://api.tianditu.gov.cn/geocoder?postStr={%27lon%27:116.28,%27lat%27:40.1419,%27ver%27:1}&type=geocode&tk=3bd24441a20ee975f046a8d7417b936a";
        final JsonBuilder jsonBuilder = new JsonBuilder(this);
//        jsonBuilder.put("doctorMobile", etPhone.getText().toString());

        MyHttpClient
                .newBuilder()
                .get()
                .url(url)
//                .addParam(jsonBuilder.toJsonString())
                .build()
                .enqueue(new BaseCallBack<String>() {
                    @Override
                    public void onSuccess(String response) {
                        super.onSuccess(response);
                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            if(TextUtils.equals(jsonObject.getString("msg"),"ok")){
                                JSONObject object = jsonObject.getJSONObject("result").getJSONObject("addressComponent");
                                String formatted_address = jsonObject.getJSONObject("result").getString("formatted_address");//建筑地址
                                String province = object.getString("province");//省
                                String city = object.getString("city");//市
                                String county = object.getString("county");//区
                                String road = "";
                                if(object.has("road")){
                                    road = object.getString("road");//街道address
                                }
                                String address = "";
                                if(object.has("address")){
                                    address = object.getString("address");//街道
                                }
                                String poi = object.getString("poi");//建筑名称
                                String county_code = object.getString("county_code");//区编码

                                if(!TextUtils.isEmpty(formatted_address)){
                                    etBuildingAddress.setText(formatted_address);
                                }
                                if(!TextUtils.isEmpty(province)){
                                    BaseFormActivity.this.province = province;
                                    BaseFormActivity.this.city = city;
                                    BaseFormActivity.this.area = county;
                                    etProvince.setText(province);
                                    etCity.setText(city);
                                    etArea.setText(area);
                                }
                                if(!TextUtils.isEmpty(road)){
                                    if(etBuildingStreet != null)
                                        etBuildingStreet.setText(road);
                                }
                                if(!TextUtils.isEmpty(address)){
                                    if(etXiaoQuMenPai != null)
                                        etXiaoQuMenPai.setText(address);
                                }
                                if(!TextUtils.isEmpty(poi)){
                                    etBuildingName.setText(poi);
                                }
                                getBuildingCode(county_code,etNumber);
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onFailure(Call call, IOException e) {
                        super.onFailure(call, e);
//                        if (myDialog != null)
//                            myDialog.dismiss();
                    }

                    @Override
                    public void onError(int code) {
                        super.onError(code);
//                        if (myDialog != null)
//                            myDialog.dismiss();
                    }
                });

    }

    /**
     * 初始化layout图片
     */

    public void initLayoutPicture(GridView gvPic) {
        W = activity.getResources().getDisplayMetrics().widthPixels;
        H = activity.getResources().getDisplayMetrics().heightPixels;
        listUrl = new ArrayList<>();
        adapter = new PictureAdapter(activity,listUrl);
        gvPic.setAdapter(adapter);
        adapter.setListener(new OnDeleteClickListener() {
            @Override
            public void onDelete(int position, ImageURL url) {
                ArrayList<ImageURL> list = new ArrayList<ImageURL>();
                for(ImageURL imageURL : listUrl){
                    if(!TextUtils.equals(imageURL.getLocalPath(),url.getLocalPath())){
                        list.add(imageURL);
                    }
                }
                listUrl = list;
                adapter.update(listUrl);
            }
        });
        //1.1  2.5  0.03 2.5 0.03 2.5 1.1
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        gvPic.setLayoutParams(lp);
        gvPic.setPadding((int) (W*0.09),Utils.dp2px(activity,10), (int) (W*0.09),Utils.dp2px(activity,10));
        gvPic.setHorizontalSpacing((int) (W*0.01));
        gvPic.setVerticalSpacing((int) (W*0.01));

    }

    public void clearImage(){
        listUrl.clear();
        adapter.update(listUrl);
    }

    public void updateImage(List<ImageURL> list){
        adapter.update(list);
    }

    public class PictureAdapter extends BaseAdapter {

        private List<ImageURL> urlList = new ArrayList<>();
        private Activity activity;
        private OnDeleteClickListener listener;
        private int width;

        public PictureAdapter(Activity activity,List<ImageURL> list){
            this.activity = activity;
            if(list != null){
                for(ImageURL url : list){
                    if(url != null){
                        urlList.add(url);
                    }
                }
                if(list.size() != 9){
                    ImageURL imageURL = new ImageURL();
                    imageURL.setThumbnail("");
                    urlList.add(imageURL);
                }
            }
            width = (int) (W*0.26);
        }

        @Override
        public int getCount() {
            return urlList == null ? 0 : urlList.size();
        }

        @Override
        public Object getItem(int position) {
            return urlList.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            final ImageURL url = urlList.get(position);
            if(!TextUtils.isEmpty(url.getThumbnail())){
                //4   8   1  8   1  8   4
                convertView = View.inflate(activity,R.layout.item_form_image,null);
                ImageView imageView = convertView.findViewById(R.id.picImageView);
                RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
                lp.width = width;
                lp.height = width;
                imageView.setLayoutParams(lp);
                ImageView deleteView = convertView.findViewById(R.id.closeImageView);
//                String str = "file://"+url;
//                Bitmap newBt = BitmapFactory.decodeFile(url);
//                Bitmap bitmap = ImageUtils.circleBitmapByShader(newBt,width-5,5);
//                imageView.setImageBitmap(bitmap);

                Glide.with(activity)
                        .load(url.getThumbnail())
                        .asBitmap()
                        .centerCrop()
                        .into(imageView);
                deleteView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if(listener != null){
                            listener.onDelete(position,url);
                        }
                    }
                });
            }else{
                convertView = View.inflate(activity,R.layout.item_form_image_add,null);
                RelativeLayout layout = convertView.findViewById(R.id.picLayoutItem);
                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width-5,width-5);
                lp.addRule(RelativeLayout.CENTER_IN_PARENT);
                layout.setLayoutParams(lp);
                convertView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if(urlList.size() >= 6){
                            CustomToast.showToast(activity,"最多选择5张图片");
                            return;
                        }
                        selectImage();
                    }
                });
            }
            return convertView;
        }

        public void update(List<ImageURL> list){
            urlList.clear();
            if(list != null){
                for(ImageURL url : list){
                    if(url != null){
                        urlList.add(url);
                    }
                }
                if(list.size() != 5){
                    ImageURL imageURL = new ImageURL();
                    imageURL.setThumbnail("");
                    urlList.add(imageURL);
                }
            }
            notifyDataSetChanged();
        }
        public void setListener(OnDeleteClickListener listener){
            this.listener = listener;
        }

    }

    public interface OnDeleteClickListener{
        void onDelete(int position, ImageURL url);
    }




    public void setImage(String imageUlr){

    }


        public  interface SelectPermissionCallBack{
            void onGranted();
        }

}
